/**
 * @file keypad.h
 * @brief COSC361 - MCU Jukebox Project\n
 * Group: Hamish Cumming, Brian Thorne\n
 * Latest source can be obtained using SVN from google's code repository with the following command:\n
 * svn checkout http://mega8-hob.googlecode.com/svn/trunk/ jukebox-hamish-brian\n
 * Description: Header file for the keypad module\n
 * Date: 25/5/2008
 */

#ifndef keypad_h
#define keypad_h

/* Col 1 */
#define KEYPAD1 0x0001
#define KEYPAD4 0x0002
#define KEYPAD7 0x0004
#define KEYPADA 0x0008
/* Col 2 */
#define KEYPAD2 0x0010
#define KEYPAD5 0x0020
#define KEYPAD8 0x0040
#define KEYPAD0 0x0080
/* Col 3 */
#define KEYPAD3 0x0100
#define KEYPAD6 0x0200
#define KEYPAD9 0x0400
#define KEYPADB 0x0800
/* Col 4 */
#define KEYPADF 0x1000
#define KEYPADE 0x2000
#define KEYPADD 0x4000
#define KEYPADC 0x8000

#define KEYPAD_ROW1KEYS (KEYPAD1|KEYPAD2|KEYPAD3|KEYPADF)
#define KEYPAD_ROW2KEYS (KEYPAD4|KEYPAD5|KEYPAD6|KEYPADE)
#define KEYPAD_ROW3KEYS (KEYPAD7|KEYPAD8|KEYPAD9|KEYPADD)
#define KEYPAD_ROW4KEYS (KEYPADA|KEYPAD0|KEYPADB|KEYPADC)

#define KEYPAD_COL1KEYS (KEYPAD1|KEYPAD4|KEYPAD7|KEYPADA)
#define KEYPAD_COL2KEYS (KEYPAD2|KEYPAD5|KEYPAD8|KEYPAD0)
#define KEYPAD_COL3KEYS (KEYPAD3|KEYPAD6|KEYPAD9|KEYPADB)
#define KEYPAD_COL4KEYS (KEYPADF|KEYPADE|KEYPADD|KEYPADC)

#define BUTTON_PLAY 15
#define BUTTON_STOP 14
#define BUTTON_VOL_UP 13
#define BUTTON_VOL_DOWN 12
#define BUTTON_NEXT 11
#define BUTTON_PREV 10

/* Globals */
/*
Let the following key assigments be used 
F = Play Pause (button 15)
E = Stop (14)
D = Volume Up
C = Volume Down
B = Next 
A = Previous 10
*/

static const unsigned int keymap[16] = {KEYPAD1,KEYPAD2,KEYPAD3,KEYPAD4,KEYPAD5,KEYPAD6,KEYPAD7,KEYPAD8,KEYPAD9,KEYPAD0,KEYPADA,KEYPADB,KEYPADC,KEYPADD,KEYPADE,KEYPADF};

/* Prototypes */
unsigned int keypad_scan(void);
void keypad_init(void);
unsigned int keypad_getKeys(void);
#endif
